#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e3 + 10;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
ll a, b, c;
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void solve()
{
    char h;
    cin >> a >> h >> b >> h >> c;
    for (int y = 1960; y <= 2059;y++)
    {
        if((y%4==0&&y%100!=0)||(y%400==0))
        {
            month[2] = 29;
        }
        else
            month[2] = 28;
        for (int m = 1; m <= 12;m++)
        {
            for (int d = 1; d <= month[m]; ++d)
            {
                if ((y % 100 == a && m == b && d == c) || (m == a && d == b && y % 100 == c) || (d == a && m == b && y % 100 == c))
                {
                    printf("%d-%02d-%02d\n", y, m, d);
                }
            }
        }
    }
}
int main()
{
    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}